package com.lry.basic.spring.ioc.util;

/**
 * @author:刘仁有
 * @desc:
 * @email:953506233@qq.com
 * @data:2019/11/18
 */
public class Common {
    /**
     * 首字母转小写
     * @param s
     * @return
     */
    public static String toLowerCaseFirstOne(String s){
        if(Character.isLowerCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
    }

    public static Object getBaseValue(Class<?>type,Object realVal){
        if(type==int.class||type==Integer.class){
            realVal = Integer.parseInt(realVal.toString());
        }else if(type==double.class||type==Double.class){
            realVal = Double.parseDouble(realVal.toString());
        }else if(type==float.class||type==Float.class){
            realVal = Float.parseFloat(realVal.toString());
        }else if(type==boolean.class||type==Boolean.class){
            realVal = Boolean.parseBoolean(realVal.toString());
        }else if(type==long.class||type==Long.class){
            realVal = Long.parseLong(realVal.toString());
        }else if(type==byte.class||type==Byte.class){
            realVal = Byte.parseByte(realVal.toString());
        }else if(type==short.class||type==Short.class){
            realVal = Short.parseShort(realVal.toString());
        }else if(type==char.class||type==Character.class){//无奈之举
            realVal = 'A';
        }
        return realVal;
    }
}
